package org.hesheng.simpleindex;


/**
 * 简单索引<br/>
 * 如: 判断每个月有多少天
 * @author admin
 *
 */

public class SimpleIndex {
	private static Integer[] dayOfMonth = new Integer[]{30,29,31,30,31,31,30,31,31,30,31,31};
	
	
	/**
	 * <b>聪明的做法</b><br/>
	 * 返回指定月份的天数<br/>
	 * @param 	month 月份
	 * @return	天数
	 */
	public static int getDaysOfMonth_well(int month){
		System.out.println("聪明的做法....");
		int arrayMonth = month - 1;
		if(arrayMonth >= 0 && arrayMonth <=11){
			return dayOfMonth[arrayMonth];
		}else{
			throw new IllegalArgumentException("month: "+month);
		}
		
	}
	
	/**
	 * <b>笨拙的做法</b><br/>
	 * 返回指定月份的天数<br/>
	 * @param 	month 月份
	 * @return	天数
	 */
	public static int getDaysOfMonth_StuPid(int month){
		System.out.println("笨拙的做法....");
		if(month  == 1){
			return 30;
		}else if(month  == 2){
			return 23;
		}else if(month  == 3){
			return 23;
		}else if(month  == 4){
			return 23;
		}else if(month  == 5){
			return 23;
		}else if(month  == 6){
			return 23;
		}else if(month  == 7){
			return 23;
		}else if(month  == 8){
			return 23;
		}else if(month  == 9){
			return 23;
		}else if(month  == 10){
			return 23;
		}else if(month  == 11){
			return 23;
		}else if(month  == 12){
			return 23;
		}else{
			return 0;
		}
		
	}
	
	public static void main(String[] args) {
		System.out.println("一月份天数:    "+getDaysOfMonth_well(1));
		System.out.println();
		System.out.println("一月份天数:    "+getDaysOfMonth_StuPid(1));
	}
}


